package com.example.demo.controller;

import com.example.demo.service.UserService;
import com.example.demo.vo.Result;
import com.example.demo.vo.params.UpdateUserParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/currentUser")
    public Result currentUser(@RequestHeader("Authorization") String token){
        // 获取现在的用户信息
        return userService.findUserByToken(token);
    }

    @GetMapping("deleteUser/{id}")
    public Result deleteUser(@PathVariable int id){
        return userService.deleteUser(id);
    }

    @PostMapping("updateUser")
    public Result updateUser(@RequestBody UpdateUserParams params){
        return userService.updateUser(params);
    }

}
